//对axios二次封装

import axios from "axios";
import nprogress from "nprogress";//引入进度条
import "nprogress/nprogress.css"
const requests = axios.create({
  // baseURL: 'http://gmall-h5-api.atguigu.cn/api',
  baseURL: '/mock',
  timeout: 5000,
})

requests.interceptors.request.use((config) => {//请求拦截器

  nprogress.start();
  return config
})

requests.interceptors.response.use((res) => {//响应拦截器
  nprogress.done()
  return res.data
}, (error) => {
  return Promise.reject(new Error('faile'))
})



export default requests;